#ifndef _STATUS_H
#define _STATUS_H

#define STATUS_PLAY_CODE		BIT0
#define STATUS_SEND_STR			BIT1
#define STATUS_SEND_BIN			BIT2
#define STATUS_REC_STR			BIT3
#define STATUS_REC_BIN			BIT4
#define STATUS_INPUT_CODE		BIT5
#define STATUS_SPEAK			BIT6
#define STATUS_WIFI_CONNECTED	BIT7
#define STATUS_WS_INIT_DONE		BIT9
#define STATUS_WS_CONNECTED		BIT10
#define STATUS_WIFI_AP_OK		BIT11
#define STATUS_SPIFFS_OK		BIT12
#define STATUS_NOET				BIT13

static uint32_t statusBit = 0;

void statusSet(uint32_t item);
void statusClear(uint32_t item);
bool statusCheck(uint32_t item);
void statusShow();

void print_bin(int number){
    int bit = sizeof(int)*8;
    int i;
    for(i = bit - 1;i >= 0;i--){
        int bin = (number & (1 << i)) >> i;
        printf("%d", bin);
		if(i % 4 == 0) {
			printf(" ");
		}
    }
    printf("\n");
}

void statusShow() {
	print_bin(statusBit);
}

void statusSet(uint32_t item) {
	statusBit = statusBit | item;
}
void statusClear(uint32_t item) {
	statusBit = statusBit & ~item;
}

bool statusCheck(uint32_t item) {
	if((statusBit & item) != item) {
		return false;
	}
	else {
		return true;
	}
}
#endif